package com.cw.myset;

import java.util.LinkedHashSet;

public class LinkedHashSetDemo {
    public static void main(String[] args) {
        //1.创建4个学生对象
        Student s1 = new Student("lisi", 23);
        Student s2 = new Student("zhangsan", 24);
        Student s3 = new Student("wangwu", 25);
        Student s4 = new Student("zhangsan", 24);

        //2.创建集合的对象
        LinkedHashSet<Student> studentLinkedHashSet = new LinkedHashSet<>();

        //3.添加元素
        System.out.println(studentLinkedHashSet.add(s1));
        System.out.println(studentLinkedHashSet.add(s2));
        System.out.println(studentLinkedHashSet.add(s3));
        System.out.println(studentLinkedHashSet.add(s4));

        //4.打印集合
        System.out.println(studentLinkedHashSet);
    }
}
